package me.gacl.websocket.JSR356.example;

import javax.websocket.*;
import java.io.IOException;

/**
 * Created by 孤傲苍狼 on 2016/2/18.
 */
@Deprecated
@ClientEndpoint
public class WebSocketClientEndpoint {

    @OnOpen
    public void onOpen(Session session) {
        System.out.println("Connected to endpoint:"+ session.getBasicRemote());
        System.out.println("Session的SessionId为:"+ session.getId());
        try {
            session.getBasicRemote().sendText("Hello");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @OnMessage
    public void onMessage(String message) {
        System.out.println(message);
    }

    @OnError
    public void onError(Throwable t) {
        t.printStackTrace();
    }
}
